<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');
    class Category_m extends CI_Model {
        public function __construct() {
             
        }
        
        function get_all_category() {
            $query = $this->db->get('category');
            return $query->result_array();
        }
        
        function get_category_item ($name) {
            $replace_name =  str_replace("_"," ", $name); 
            $this->db->where('category_name', $replace_name);
            $query = $this->db->get('category');
            return $query->row_array();
        }
        
        function insert_category($data){
            $this->db->set('category_name', $data);
            $this->db->insert('category');
        }
        
        function update_category($data) {
            $this->db->set('category_name', $data);
            $this->db->update('category');
        }
        
        function delete_category($cat_id) {
            $this->db->where('category_id', $cat_id);
            $this->db->delete('category');
        }
    }
?>
